<?php
/*
* ----------------------------------------------------------------------------------------------------
* Block of header
* @PACKAGE BY TT from Themecenter.net
* ----------------------------------------------------------------------------------------------------
*/

#
#Styles For The Front
#
function  TT_load_styles() 
{	
	$slider_type=get_theme_option('slideshow','slider_type');
	$slideshow_type=get_theme_option('slideshow','slideshow_type');
	
	$general_fonts = get_theme_option('font','body_font_family');
    $menu_fonts = get_theme_option('font','nav_font_family');
    $heading_fonts = get_theme_option('font','headings_font_family');
	if(!is_admin())
	{

		wp_register_style('style', THEME_URI.'/style.css', false, THEME_VERSION, 'screen');
		wp_enqueue_style('style');
		
		// Load cufont font for skin (All skin using cufont font)

		/* Load slider */
		if(($slider_type == 'slider_type_diapo' && $slideshow_type == 'slideshow_type_slider')) :
    		wp_register_style('diapo', CSS_URI.'/diapo.css', false, THEME_VERSION, 'screen');
    		wp_enqueue_style('diapo');
    		elseif (($slider_type == 'slider_type_skitter' && $slideshow_type == 'slideshow_type_slider')) :
    		wp_register_style('skitter', CSS_URI.'/skitter.css', false, THEME_VERSION, 'screen');
    		wp_enqueue_style('skitter');		
    		elseif (($slider_type == 'slider_type_nivo' && $slideshow_type == 'slideshow_type_slider')) : 
    		wp_register_style('nivo', CSS_URI.'/nivo.css', false, THEME_VERSION, 'screen');
    		wp_enqueue_style('nivo');		
    		elseif (($slider_type == 'slider_type_zaccordion')) : 
    		wp_register_style('zaccordion', CSS_URI.'/zaccordion.css', false, THEME_VERSION, 'screen');
    		wp_enqueue_style('zaccordion');		
    		elseif (($slideshow_type == 'slideshow_type_image')) :
    		wp_register_style('diapo', CSS_URI.'/diapo.css', false, THEME_VERSION, 'screen');
    		wp_enqueue_style('diapo');		
		endif;
		/* End load slider */
		wp_register_style('prettyPhoto', CSS_URI.'/prettyPhoto.css', false, THEME_VERSION, 'screen');
		wp_enqueue_style('prettyPhoto');

	}
}
add_action("wp_print_styles", 'TT_load_styles');

#
# JavaSrcipts For The Front
#
function  TT_load_scripts() 
{	
	$slider_type=get_theme_option('slideshow','slider_type');
	$slideshow_type=get_theme_option('slideshow','slideshow_type');
	if(isset($_GET['slider'])){ $_SESSION['slider'] = $_GET['slider'];}
	if(!is_admin())
	{
		wp_enqueue_script('jquery');
		// Jquery Easing
		wp_register_script( 'jqueryeasing12', JS_URI. '/libs/jquery.easing.1.3.js', false, THEME_VERSION );
		wp_enqueue_script('jqueryeasing12');
		// Hover Intent
		//wp_register_script( 'hoverIntent12', JS_URI. '/libs/jquery.hoverIntent.minified.js', false, THEME_VERSION );
		wp_enqueue_script('hoverIntent');
		// superfish - Menu
		
		// prettyPhoto
		wp_register_script( 'prettyPhoto', JS_URI. '/libs/jquery.prettyPhoto.js', false, THEME_VERSION );
		//wp_enqueue_script('prettyPhoto');
		
		// quovolver
		wp_register_script( 'quovolver', JS_URI. '/libs/jquery.quovolver.js', false, THEME_VERSION );
		//wp_enqueue_script('quovolver');
		
		// tweet
		wp_register_script( 'tweet', JS_URI. '/libs/jquery.tweet.js', false, THEME_VERSION );
		//wp_enqueue_script('tweet');

		// tweet
		wp_register_script( 'mosaic', JS_URI. '/libs/mosaic.1.0.1.js', false, THEME_VERSION );
		wp_enqueue_script('mosaic');

		// theme_plugin
		wp_register_script( 'theme_plugin', JS_URI. '/plugins.js', false, THEME_VERSION );
		wp_enqueue_script('theme_plugin');
		
		// theme_script
		wp_register_script( 'theme_script', JS_URI. '/script.js', false, THEME_VERSION );
		wp_enqueue_script('theme_script');
		
		// modernizr
		wp_register_script( 'modernizr', JS_URI. '/libs/modernizr-2.5.3.min.js', false, THEME_VERSION );
		wp_enqueue_script('modernizr');		
		
		// modernizr
		wp_register_script( 'filterable', JS_URI. '/libs/filterable.pack.js', false, THEME_VERSION );
			
		
		
		if(($slider_type == 'slider_type_diapo'  && $slideshow_type == 'slideshow_type_slider')) :
		// Diapo
		wp_register_script( 'diapo', JS_URI. '/libs/diapo.js', false, THEME_VERSION );
		wp_enqueue_script('diapo');
		elseif(($slider_type == 'slider_type_skitter'  && $slideshow_type == 'slideshow_type_slider'))	:
		wp_register_script( 'skitter', JS_URI. '/libs/jquery.skitter.js', false, THEME_VERSION );
		wp_enqueue_script('skitter');
		elseif(($slider_type == 'slider_type_nivo'  && $slideshow_type == 'slideshow_type_slider')):
		wp_register_script( 'nivo', JS_URI. '/libs/jquery.nivo.slider.js', false, THEME_VERSION );
		wp_enqueue_script('nivo');
		elseif(($slider_type == 'slider_type_zaccordion'  && $slideshow_type == 'slideshow_type_slider')) :
		wp_register_script( 'zaccordion', JS_URI. '/libs/jquery.zaccordion.js', false, THEME_VERSION );
		wp_enqueue_script('zaccordion');
		
		endif;
		// Validator
		wp_register_script( 'validate', JS_URI. '/libs/jquery.validate.js', false, THEME_VERSION );

		// Google Map Api
		wp_register_script( 'google_map', 'https://maps.googleapis.com/maps/api/js?sensor=false', false, THEME_VERSION );

		wp_register_script( 'gmap', JS_URI. '/libs/gmap.js', false, THEME_VERSION );

	}
}

add_action('wp_print_scripts', 'TT_load_scripts');


function tt_other_meta_load()
{
echo '
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<link rel="apple-touch-icon-precomposed" href="apple-touch-icon.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="apple-touch-icon-57x57.png" />
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="apple-touch-icon-72x72.png" />
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="apple-touch-icon-114x114.png" />';
}
add_action('wp_head', 'tt_other_meta_load');
#
# Add favicon icon
#
function tt_load_favicon_icon() 
{
	$favicon = get_theme_option('general','custom_favicon');
	if ($favicon) { echo '<link rel="shortcut icon" href="'.$favicon.'" />',"\n"; }
}
add_action('wp_head', 'tt_load_favicon_icon');
#
# JavaSrcipts For IE
#
function tt_load_ie_srcipts() 
{
	echo ''."\n";
	echo '<!--[if lt IE 9]>'."\n";
	echo '<script type="text/javascript" src="'.JS_URI.'/ie.min.js?ver='.THEME_VERSION.'"></script>'."\n";
	echo '<![endif]-->'."\n";
}

add_action('wp_head', 'tt_load_ie_srcipts');
//IE 9 fix
function IE9_fix()
{
echo '<!--[if lt IE 9]>
	<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
	<![endif]-->';
};
add_action('wp_head','IE9_fix');
// <IE7 Warring
function IE7_warring()
{
echo '<!--[if lt IE 7]><p class=chromeframe>Your browser is <em>ancient!</em> <a href="http://browsehappy.com/">Upgrade to a different browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to experience this site.</p><![endif]-->';
};
// Add script





function theme_custome_style()
{
/*
Font
*/
$general_fonts = get_theme_option('font','body_font_family');
$menu_fonts = get_theme_option('font','nav_font_family');
$heading_fonts = get_theme_option('font','headings_font_family');
$heading_fonts_weight = get_theme_option('font','headings_font_weight');
/*
Fontsize
*/
$general_fontsize = get_theme_option('font','general_font_size');
$menu_fontsize = get_theme_option('font','menu_font_size');
$sub_menu_font_size = get_theme_option('font','sub_menu_font_size');
$h1_font_size = get_theme_option('font','h1_font_size');
$h2_font_size = get_theme_option('font','h2_font_size');
$h3_font_size = get_theme_option('font','h3_font_size');
$h4_font_size = get_theme_option('font','h4_font_size');
$h5_font_size = get_theme_option('font','h5_font_size');
$h6_font_size = get_theme_option('font','h6_font_size');

/*
Skin selected
*/


$style_skin_selected = get_theme_option('style','style_skin_selected');
if($style_skin_selected == 'yellow' && get_theme_option('general','enable_using_skin_file') == 'false' && get_theme_option('general','enable_demo_link')=='false' && !isset($_SESSION['skin'])):
echo '<link rel="stylesheet" id="skin-yellow"  href="'.THEME_URI.'/css/yellow.css" type="text/css" media="all" />';
endif;
		
$return = '<style>';
$font_custome_style ='@import url(http://fonts.googleapis.com/css?family='.$general_fonts.');'."\n";
$font_custome_style .='@import url(http://fonts.googleapis.com/css?family='.$menu_fonts.');'."\n";
$font_custome_style .='@import url(http://fonts.googleapis.com/css?family='.$heading_fonts.');'."\n";

$font_custome_style .='
body{
font-family : '.str_replace("+"," ",$general_fonts).';
font-size: '.$general_fontsize.'px;
}
nav ul li a
{
font-family : '.str_replace("+"," ",$menu_fonts).';
font-size: '.$menu_fontsize.'px;
}

}
h1{
font-family : '.str_replace("+"," ",$heading_fonts).';
font-size: '.$h1_font_size.'px;
font-weight:'.$heading_fonts_weight.';
}
h2{
font-family : '.str_replace("+"," ",$heading_fonts).';
font-size: '.$h2_font_size.'px;
font-weight:'.$heading_fonts_weight.';
}
h3{
font-family : '.str_replace("+"," ",$heading_fonts).';
font-size: '.$h3_font_size.'px;
font-weight:'.$heading_fonts_weight.';
}
h4{
font-family : '.str_replace("+"," ",$heading_fonts).';
font-size: '.$h4_font_size.'px;
font-weight:'.$heading_fonts_weight.';
}
h5{
font-family : '.str_replace("+"," ",$heading_fonts).';
font-size: '.$h5_font_size.'px;
font-weight:'.$heading_fonts_weight.';
}
h6{
font-family : '.str_replace("+"," ",$heading_fonts).';
font-size: '.$h6_font_size.'px;
font-weight:'.$heading_fonts_weight.';
}';


/*
* Color
*/
$text_color = get_theme_option('style','text_color');
$link_color = get_theme_option('style','link_color');
$hover_color = get_theme_option('style','hover_color');

$body_bg_color = get_theme_option('style','body_bg_color');
$body_bg_image = get_theme_option('style','body_bg_image');
$body_bg_pattern = get_theme_option('style','body_bg_pattern');
$custom_css = get_theme_option('style','text_color');
$spacer_heading_color = get_theme_option('style','spacer_heading_color');
$menu_color = get_theme_option('style','menu_color');
$menu_hover_color = get_theme_option('style','menu_hover_color');
$h1_color =  get_theme_option('style','h1_color');
$h2_color =  get_theme_option('style','h2_color');
$h3_color =  get_theme_option('style','h3_color');
$h4_color =  get_theme_option('style','h4_color');
$h5_color =  get_theme_option('style','h5_color');
$h6_color =  get_theme_option('style','h6_color');

$font_custome_style.='
a,.siderbar-wrap h2{ color : #'.$link_color.'; }
a:hover{ color : #'.$hover_color.'; }
.sf-menu > li.current-menu-item > a,.top-bar span { color : #'.$menu_color.';  }
.sf-menu a:hover,.sf-menu ul li.sfHover { color : #'.$menu_hover_color.' !important; }
.intro-box h2, .social-icons h2{ color : #'.$link_color.';  }
h1{ color : #'.$h1_color.'; }
h2{ color : #'.$h2_color.';}
.siderbar-wrap .contact-footer span{ color : #'.$hover_color.'; }
h3{ color : #'.$h3_color.'; }
h4{ color : #'.$h4_color.'; }
h5{ color : #'.$h5_color.'; }
h6{ color : #'.$h6_color.'; }


body{ background-color:#'.$body_bg_color.'; }
body{ background-image:'.$body_bg_image.'; }
body{ background:url("'.IMAGE_URI.'/pattern/'.$body_bg_pattern.'") #'.$body_bg_color.'; }
.big-bg-h3 h3, .home-medium-bg-h3 h3, .medium-bg-h3 h3 { background-color:#'.$spacer_heading_color.'; }
.team-social a.twitter,.team-social a.facebook {background-color:#'.hex_darker($spacer_heading_color,'30').'; }
.team-social a.twitter:hover ,.team-social a.facebook:hover { background-color:#'.$h2_color.'; }

body,p{ color : #'.$text_color.'; }';
$logo_top = get_theme_option('header','position_logo_from_top');
$logo_left = get_theme_option('header','position_logo_from_left');
$position_menu_from_top = get_theme_option('header','position_menu_from_top');
$position_menu_from_left = get_theme_option('header','position_menu_from_left');
$font_custome_style.='
#logo{
margin-top:'.$logo_top.'px;
margin-left:'.$logo_left.'px;
}
nav{
margin-top:'.$position_menu_from_top.'px;
margin-left:'.$position_menu_from_left.'px;
}
';
$font_custome_style.=$custom_css;
$return .= $font_custome_style.'</style>';
if(get_theme_option('general','enable_using_skin_file')==false && get_theme_option('general','enable_demo_link') == false)
{
echo $return;
}else{
echo '
<style>
body, footer{ background-color:#'.$body_bg_color.'; }
body{ background-image:url("'.IMAGE_URI.'/pattern/'.$body_bg_pattern.'") ; }
#logo{
margin-top:'.$logo_top.'px !important;
margin-left:'.$logo_left.'px !important;
}
nav{
margin-top:'.$position_menu_from_top.'px !important;
margin-left:'.$position_menu_from_left.'px !important;
}'.$custom_css.'
</style>
';
}

}
add_action("wp_head","theme_custome_style");
function  TT_load_skin()
{
 	  $enable_demo_link = get_theme_option('general','enable_demo_link');
      $skin = get_theme_option('general','skin_selected');
	  if(isset($_GET["skin"])){$_SESSION["skin"]=$_GET["skin"];};
	  if(isset($_SESSION["skin"]) && $enable_demo_link== 'true')
	  {
	  
	     echo '<link type="text/css" href="'.CSS_URI.'/'.$_SESSION["skin"].'.css" media="all" rel="stylesheet">';

	  }
	  else if(get_theme_option('general','enable_using_skin_file')=='true')
	  {
		
		if(get_theme_option('general','skin_selected')=='yellow')
		{
	 	 echo '<link type="text/css" href="'.CSS_URI.'/yellow.css" media="all" rel="stylesheet">';
		}		
	  }
} 
function TT_load_js_skin()
{
       if(isset($_GET["slider"])){$_SESSION["slider"]=$_GET["slider"];};
	   $enable_demo_link = get_theme_option('general','enable_demo_link');
       if(isset($_SESSION['slider']) && $enable_demo_link == 'true')
          	{		
      	 		if($_SESSION['slider'] == 'slider_type_diapo')			
      			{
				
				 	 echo '<link type="text/css" href="'.CSS_URI.'/diapo.css" media="all" rel="stylesheet">';			   

      			 	 echo '<script type="text/javascript" src="'.JS_URI.'/libs/diapo.js"></script>';

      			}		
      			else if($_SESSION['slider'] == 'slider_type_skitter')			
      			{
				
				 	 echo '<link type="text/css" href="'.CSS_URI.'/skitter.css" media="all" rel="stylesheet">';			   

      			 	 echo '<script type="text/javascript" src="'.JS_URI.'/libs/jquery.skitter.js"></script>';
      			}		
      			else if($_SESSION['slider'] == 'slider_type_nivo')			
      			{
				
				 	 echo '<link type="text/css" href="'.CSS_URI.'/nivo.css" media="all" rel="stylesheet">';			   

      			 	 echo '<script type="text/javascript" src="'.JS_URI.'/libs/jquery.nivo.slider.js"></script>';
      			}
				else if($_SESSION['slider'] == 'slider_type_zaccordion')			
      			{
				
				 	 echo '<link type="text/css" href="'.CSS_URI.'/zaccordion.css" media="all" rel="stylesheet">';			   

      			 	 echo '<script type="text/javascript" src="'.JS_URI.'/libs/jquery.zaccordion.js"></script>';
      			}		
      			else if($_SESSION['slider'] == 'slider_type_image')			
      			{
				
    				 echo '<link type="text/css" href="'.CSS_URI.'/diapo.css" media="all" rel="stylesheet">';			   
      			}		
          	}
}
add_action("wp_head","TT_load_js_skin");
add_action("wp_head","TT_load_skin");
function theme_add_panel_frontend()
{
$enable_demo_link = get_theme_option('general','enable_demo_link');
if($enable_demo_link =='true'):
    echo '<link type="text/css" href="'.API_URI.'/api_asset/css/theme_center_colorpicker.css" media="all" rel="stylesheet">';			   
    echo '<link type="text/css" href="'.API_URI.'/frontpage_options/panel.css" media="all" rel="stylesheet">';			   
    echo '<script type="text/javascript" src="'.API_URI.'/api_asset/js/jquery-colorpicker.js"></script>';
	echo '<script type="text/javascript" src="'.API_URI.'/frontpage_options/panel.js"></script>';
endif;
}
add_action("wp_head","theme_add_panel_frontend");
#
#Add SEO meta
#
function theme_add_seo_meta() 
{
	$enable_seo = get_theme_option('general', 'enable_seo');
	$seo_follow = get_meta_option('seo_follow');
	$seo_noindex = get_meta_option('seo_noindex');
	$seo_keywords = get_meta_option('seo_keywords');
	$seo_description = get_meta_option('seo_description');
	$seo_title_tags = get_meta_option('seo_title_tags');

	if( is_singular() && $enable_seo == 'yes' )
	{
		if($seo_follow == true) { $seo_follow = 'follow'; } else { $seo_follow = 'nofollow'; }
		if($seo_noindex == true) { $seo_noindex = 'noindex'; } else { $seo_noindex = 'index'; }

		echo '<meta name="robots" content="'.$seo_noindex.', '.$seo_follow.'" />'."\n";

		if($seo_keywords) 
		{
		echo '<meta name="keywords" content="'.stripslashes($seo_keywords).'" />'."\n";
		}

		if($seo_description)
		{
		echo '<meta name="description" content="'.stripslashes($seo_description).'" />'."\n";
		}
	}
	echo '<!--Title-->'."\n";
	if( is_singular() && $seo_title_tags != '' && $enable_seo == 'yes' ) 
	{
		echo '<title>'.stripslashes($seo_title_tags).'</title>'."\n";
	}
	else
	{
		echo '<title>';
		wp_title('&laquo;', true, 'right');
		echo '</title>'."\n";
	}
}
function add_google_analytic()
{
   if(get_theme_option('general','Google_analytics_Code') != '')
   {
   echo '<div>'.stripslashes(get_theme_option('general','Google_analytics_Code')).'</div>';
   }
}
add_action('wp_footer','add_google_analytic');

?>